Fix InternalLogger logging hierarchy and bump to v1.1.1#18
Merged
Conversation
InternalLogger instances were not being registered with Python's logging manager, causing them to have no parent logger and preventing handler propagation. This meant that: - basicConfig() had no effect on InternalLogger instances - They couldn't inherit handlers from parent loggers - Users couldn't see SDK internal logs without manual configuration This commit fixes the issue by: 1. Registering InternalLogger instances with logging.Logger.manager.loggerDict during __init__, ensuring they participate in the logging hierarchy 2. Setting up parent loggers properly (adapted from Python's logging internals) so handlers propagate correctly 3. Fixing the prefab_internal extra attribute by overriding _log() instead of log(), since info(), debug(), etc. call _log() directly The fix is compatible with both: - Standard logging (logging.basicConfig, manual handler configuration) - Structlog (when configured to use stdlib logging) The prefab_internal=True extra attribute is still added to all log records from InternalLogger instances, allowing users to filter/identify SDK internal messages. Ported from: prefab-cloud/prefab-cloud-python#127 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes the
InternalLoggerclass to properly register with Python's logging hierarchy, enabling handler propagation fromlogging.basicConfig()and parent loggers.Problem
InternalLoggerinstances were not being registered with Python's logging manager, causing:logging.basicConfig()or parent loggersChanges
1. Logger Hierarchy Registration (
_internal_logging.py)InternalLoggerwithlogging.Logger.manager.loggerDictduring__init___fixupParents)2. Fix
prefab_internalAttributelog()to_log()methodinfo(),debug(), etc. methods call_log()directly, notlog()prefab_internal=Trueinto all log recordsextraparameter as a dictionary3. Version Bump
Testing
✅ All 364 tests pass
✅ Pre-commit hooks pass (black, ruff, prettier, mypy)
✅ Manual testing confirms logger hierarchy works correctly
✅ Logger inherits handlers from root and parent loggers
✅
prefab_internalattribute is properly set on all log recordsPorted From
This fix was originally implemented in the prefab-cloud-python repository:
prefab-cloud/prefab-cloud-python#127
🤖 Generated with Claude Code